/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pi2.osr.ejb.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.persistence.GenerationType;
import javax.persistence.SequenceGenerator;
import javax.persistence.GeneratedValue;
/**
 *
 * @author admin
 */
@Entity
@Table(catalog = "", schema = "P09713_2_10")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Pagina.findAll", query = "SELECT p FROM Pagina p"),
    @NamedQuery(name = "Pagina.findByIdpagina", query = "SELECT p FROM Pagina p WHERE p.idpagina = :idpagina"),
    @NamedQuery(name = "Pagina.findByNombre", query = "SELECT p FROM Pagina p WHERE p.nombre = :nombre")})
public class Pagina implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @SequenceGenerator(name="PAGINA_IDPAGINA_GENERATOR", sequenceName="PAGINA_SEQ", allocationSize=1)
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="PAGINA_IDPAGINA_GENERATOR")
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false, precision = 0, scale = -127)
    private BigDecimal idpagina;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(nullable = false, length = 100)
    private String nombre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(nullable = false, length = 100)
    private String url;
    @JoinTable(name = "ROLPAGINAS", joinColumns = {
        @JoinColumn(name = "IDPAGINA", referencedColumnName = "IDPAGINA", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "IDROL", referencedColumnName = "IDROL", nullable = false)})
    @ManyToMany(fetch = FetchType.LAZY)
    private List<Rol> rolList;

    public Pagina() {
    }

    public Pagina(BigDecimal idpagina) {
        this.idpagina = idpagina;
    }

    public Pagina(BigDecimal idpagina, String nombre,String url) {
        this.idpagina = idpagina;
        this.nombre = nombre;
        this.url = url;
    }

    public BigDecimal getIdpagina() {
        return idpagina;
    }

    public void setIdpagina(BigDecimal idpagina) {
        this.idpagina = idpagina;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    @XmlTransient
    public List<Rol> getRolList() {
        return rolList;
    }

    public void setRolList(List<Rol> rolList) {
        this.rolList = rolList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idpagina != null ? idpagina.hashCode() : 0);
        return hash;
    }
    

    public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pagina)) {
            return false;
        }
        Pagina other = (Pagina) object;
        if ((this.idpagina == null && other.idpagina != null) || (this.idpagina != null && !this.idpagina.equals(other.idpagina))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.pi2.osr.ejb.entites.Pagina[ idpagina=" + idpagina + " ]";
    }
    
}
